namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0034 : DbMigration
    {
        public override void Up()
        {
            //RenameTable(name: "dbo.FimPay", newName: "fim_payments");
            //RenameTable(name: "dbo.FimPayCheque", newName: "fim_payment_cheques");
            //DropForeignKey("dbo.FimPay", "BgSourceId", "dbo.bgm_mas_source");
            //DropForeignKey("dbo.FimPay", "WorkAreaId", "dbo.hrm_mp_work_areas");
            //DropForeignKey("dbo.FimPay", "PayReqId", "dbo.fim_money_requests");
            //DropForeignKey("dbo.FimPay", "PetitionId", "dbo.FimPetition");
            //DropForeignKey("dbo.FimPay", "PetitionDtlId", "dbo.FimPetitionDtl");
            //DropForeignKey("dbo.FimPay", "EmpId", "dbo.hrm_ps_employees");
            //DropForeignKey("dbo.FimPay", "ContactId", "dbo.IcmMasContact");
            //DropForeignKey("dbo.FimPay", "BidderColId", "dbo.IcmBidderCollateral");
            //DropForeignKey("dbo.FimPay", "PostPayId", "dbo.FimPay");
            //DropForeignKey("dbo.FimPay", "TranGrpId", "dbo.AcmTransectionGroup");
            //DropIndex("dbo.FimPay", new[] { "BgSourceId" });
            //DropIndex("dbo.FimPay", new[] { "WorkAreaId" });
            //DropIndex("dbo.FimPay", new[] { "PayReqId" });
            //DropIndex("dbo.FimPay", new[] { "PetitionId" });
            //DropIndex("dbo.FimPay", new[] { "PetitionDtlId" });
            //DropIndex("dbo.FimPay", new[] { "EmpId" });
            //DropIndex("dbo.FimPay", new[] { "ContactId" });
            //DropIndex("dbo.FimPay", new[] { "BidderColId" });
            //DropIndex("dbo.FimPay", new[] { "PostPayId" });
            //DropIndex("dbo.FimPay", new[] { "TranGrpId" });
            //RenameColumn(table: "dbo.fim_payments", name: "PayId", newName: "pay_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "BgSourceId", newName: "bgm_source_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "WorkAreaId", newName: "work_area_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "BgYear", newName: "bgm_year");
            //RenameColumn(table: "dbo.fim_payments", name: "PayEventId", newName: "event_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "PayDate", newName: "pay_date");
            //RenameColumn(table: "dbo.fim_payments", name: "RealPayDate", newName: "real_pay_date");
            //RenameColumn(table: "dbo.fim_payments", name: "Code", newName: "ref_no");
            //RenameColumn(table: "dbo.fim_payments", name: "ReceiptNo", newName: "receipt_no");
            //RenameColumn(table: "dbo.fim_payments", name: "ReceiptName", newName: "receipt_name");
            //RenameColumn(table: "dbo.fim_payments", name: "Name", newName: "pay_name");
            //RenameColumn(table: "dbo.fim_payments", name: "PayMethodId", newName: "method_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "PayReqId", newName: "money_req_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "PetitionId", newName: "petition_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "PetitionDtlId", newName: "petition_dtls_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "EmpId", newName: "emp_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "ContactId", newName: "contact_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "TempContactName", newName: "temp_contact_name");
            //RenameColumn(table: "dbo.fim_payments", name: "BidderColId", newName: "bidder_col_id");
            //RenameColumn(table: "dbo.fim_payments", name: "VatRate", newName: "vat_rate");
            //RenameColumn(table: "dbo.fim_payments", name: "TaxRate", newName: "tax_rate");
            //RenameColumn(table: "dbo.fim_payments", name: "NetAmount", newName: "net_amount");
            //RenameColumn(table: "dbo.fim_payments", name: "PostPayId", newName: "post_pay_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "TranGrpId", newName: "tran_grp_seq");
            //RenameColumn(table: "dbo.fim_payments", name: "RecordStatus", newName: "record_status");
            //RenameColumn(table: "dbo.fim_payments", name: "CreatedBy", newName: "created_by");
            //RenameColumn(table: "dbo.fim_payments", name: "CreatedWhen", newName: "created_when");
            //RenameColumn(table: "dbo.fim_payments", name: "UpdatedBy", newName: "updated_by");
            //RenameColumn(table: "dbo.fim_payments", name: "UpdatedWhen", newName: "updated_when");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "PayChequeId", newName: "pay_cheque_seq");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "PayId", newName: "pay_seq");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "ChequeId", newName: "cheque_seq");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "RecordStatus", newName: "record_status");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "CreatedBy", newName: "created_by");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "CreatedWhen", newName: "created_when");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "UpdatedBy", newName: "updated_by");
            //RenameColumn(table: "dbo.fim_payment_cheques", name: "UpdatedWhen", newName: "updated_when");
            //AlterColumn("dbo.fim_payments", "amount", c => c.Decimal(precision: 18, scale: 2));
            //AlterColumn("dbo.fim_payments", "vat", c => c.Decimal(precision: 18, scale: 2));
            //AlterColumn("dbo.fim_payments", "tax", c => c.Decimal(precision: 18, scale: 2));
            //AlterColumn("dbo.fim_payments", "remarks", c => c.String());
            //AlterColumn("dbo.fim_payment_cheques", "amount", c => c.Decimal(precision: 18, scale: 2));
        }
        
        public override void Down()
        {
            AlterColumn("dbo.fim_payment_cheques", "Amount", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.fim_payments", "Remarks", c => c.String());
            AlterColumn("dbo.fim_payments", "Tax", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.fim_payments", "Vat", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.fim_payments", "Amount", c => c.Decimal(precision: 18, scale: 2));
            RenameColumn(table: "dbo.fim_payment_cheques", name: "updated_when", newName: "UpdatedWhen");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "updated_by", newName: "UpdatedBy");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "created_when", newName: "CreatedWhen");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "created_by", newName: "CreatedBy");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "record_status", newName: "RecordStatus");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "cheque_seq", newName: "ChequeId");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "pay_seq", newName: "PayId");
            RenameColumn(table: "dbo.fim_payment_cheques", name: "pay_cheque_seq", newName: "PayChequeId");
            RenameColumn(table: "dbo.fim_payments", name: "updated_when", newName: "UpdatedWhen");
            RenameColumn(table: "dbo.fim_payments", name: "updated_by", newName: "UpdatedBy");
            RenameColumn(table: "dbo.fim_payments", name: "created_when", newName: "CreatedWhen");
            RenameColumn(table: "dbo.fim_payments", name: "created_by", newName: "CreatedBy");
            RenameColumn(table: "dbo.fim_payments", name: "record_status", newName: "RecordStatus");
            RenameColumn(table: "dbo.fim_payments", name: "tran_grp_seq", newName: "TranGrpId");
            RenameColumn(table: "dbo.fim_payments", name: "post_pay_seq", newName: "PostPayId");
            RenameColumn(table: "dbo.fim_payments", name: "net_amount", newName: "NetAmount");
            RenameColumn(table: "dbo.fim_payments", name: "tax_rate", newName: "TaxRate");
            RenameColumn(table: "dbo.fim_payments", name: "vat_rate", newName: "VatRate");
            RenameColumn(table: "dbo.fim_payments", name: "bidder_col_id", newName: "BidderColId");
            RenameColumn(table: "dbo.fim_payments", name: "temp_contact_name", newName: "TempContactName");
            RenameColumn(table: "dbo.fim_payments", name: "contact_seq", newName: "ContactId");
            RenameColumn(table: "dbo.fim_payments", name: "emp_seq", newName: "EmpId");
            RenameColumn(table: "dbo.fim_payments", name: "petition_dtls_seq", newName: "PetitionDtlId");
            RenameColumn(table: "dbo.fim_payments", name: "petition_seq", newName: "PetitionId");
            RenameColumn(table: "dbo.fim_payments", name: "money_req_seq", newName: "PayReqId");
            RenameColumn(table: "dbo.fim_payments", name: "method_seq", newName: "PayMethodId");
            RenameColumn(table: "dbo.fim_payments", name: "pay_name", newName: "Name");
            RenameColumn(table: "dbo.fim_payments", name: "receipt_name", newName: "ReceiptName");
            RenameColumn(table: "dbo.fim_payments", name: "receipt_no", newName: "ReceiptNo");
            RenameColumn(table: "dbo.fim_payments", name: "ref_no", newName: "Code");
            RenameColumn(table: "dbo.fim_payments", name: "real_pay_date", newName: "RealPayDate");
            RenameColumn(table: "dbo.fim_payments", name: "pay_date", newName: "PayDate");
            RenameColumn(table: "dbo.fim_payments", name: "event_seq", newName: "PayEventId");
            RenameColumn(table: "dbo.fim_payments", name: "bgm_year", newName: "BgYear");
            RenameColumn(table: "dbo.fim_payments", name: "work_area_seq", newName: "WorkAreaId");
            RenameColumn(table: "dbo.fim_payments", name: "bgm_source_seq", newName: "BgSourceId");
            RenameColumn(table: "dbo.fim_payments", name: "pay_seq", newName: "PayId");
            CreateIndex("dbo.FimPay", "TranGrpId");
            CreateIndex("dbo.FimPay", "PostPayId");
            CreateIndex("dbo.FimPay", "BidderColId");
            CreateIndex("dbo.FimPay", "ContactId");
            CreateIndex("dbo.FimPay", "EmpId");
            CreateIndex("dbo.FimPay", "PetitionDtlId");
            CreateIndex("dbo.FimPay", "PetitionId");
            CreateIndex("dbo.FimPay", "PayReqId");
            CreateIndex("dbo.FimPay", "WorkAreaId");
            CreateIndex("dbo.FimPay", "BgSourceId");
            AddForeignKey("dbo.FimPay", "TranGrpId", "dbo.AcmTransectionGroup", "TranGrpId");
            AddForeignKey("dbo.FimPay", "PostPayId", "dbo.FimPay", "PayId");
            AddForeignKey("dbo.FimPay", "BidderColId", "dbo.IcmBidderCollateral", "BidderColId");
            AddForeignKey("dbo.FimPay", "ContactId", "dbo.IcmMasContact", "ConId");
            AddForeignKey("dbo.FimPay", "EmpId", "dbo.hrm_ps_employees", "emp_seq");
            AddForeignKey("dbo.FimPay", "PetitionDtlId", "dbo.FimPetitionDtl", "PetitionDtlId");
            AddForeignKey("dbo.FimPay", "PetitionId", "dbo.FimPetition", "PetitionId");
            AddForeignKey("dbo.FimPay", "PayReqId", "dbo.fim_money_requests", "money_req_seq");
            AddForeignKey("dbo.FimPay", "WorkAreaId", "dbo.hrm_mp_work_areas", "work_area_seq", cascadeDelete: true);
            AddForeignKey("dbo.FimPay", "BgSourceId", "dbo.bgm_mas_source", "bgm_source_seq", cascadeDelete: true);
            RenameTable(name: "dbo.fim_payment_cheques", newName: "FimPayCheque");
            RenameTable(name: "dbo.fim_payments", newName: "FimPay");
        }
    }
}
